import Vue from 'vue'
import VueRouter from 'vue-router'
import VueQuillEditor from 'vue-quill-editor'
// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

// 引入对应的组件
import Login from '@/views/Login.vue'
import Home from '@/views/Home.vue'
import Welcome from '@/views/Welcome.vue'
import Users from '@/views/users/index.vue'
import Right from '@/views/rightControl/Right.vue'
import Role from '@/views/rightControl/Role.vue'
import Goods from '@/views/goods/Goods.vue'
import List from '@/views/goods/List.vue'
import Add from '@/views/goods/Add.vue'
import Reports from '@/views/reports/Reports.vue'

Vue.use(VueRouter)
Vue.use(VueQuillEditor)

// 创建路由对象
var router = new VueRouter({
  routes: [
    {
      path: '/',
      redirect: { name: 'home' } // 从定向
    },
    {
      name: 'login',
      path: '/login',
      component: Login
    },
    {
      name: 'home',
      path: '/home',
      component: Home,
      redirect: { path: '/home/wel' },
      children: [
        {
          path: 'wel', // 嵌套路由不用加/
          component: Welcome
        },
        {
          name: 'users',
          path: 'users', // 嵌套路由不用加/
          component: Users
        },
        {
          name: 'rights',
          path: 'rights', // 嵌套路由不用加/
          component: Right
        },
        {
          name: 'roles',
          path: 'roles', // 嵌套路由不用加/
          component: Role
        },
        {
          name: 'goods',
          path: 'goods', // 嵌套路由不用加/
          component: Goods,
          redirect: { path: '/home/goods/list' },
          children: [
            {
              name: 'list',
              path: 'list', // 嵌套路由不用加/
              component: List
            },
            {
              name: 'add',
              path: 'add', // 嵌套路由不用加/
              component: Add
            }
          ]
        },
        {
          name: 'reports',
          path: 'reports', // 嵌套路由不用加/
          component: Reports
        }
      ]
    }
  ]
})

export default router
